﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;

namespace JiveMessenger.Models
{
    public class LogFileModel:INotifyPropertyChanged
    {
        private DateTime _lastWriteTime;
        public DateTime LastWriteTime
        {
            get { return _lastWriteTime; }
            set
            {
                if (_lastWriteTime != value)
                {
                    _lastWriteTime = value;
                    RaisePropertyChanged("LastWriteTime");
                }
            }
        }

        private string _fileName;
        public string FileName
        {
            get { return _fileName; }
            set
            {
                if (_fileName != value)
                {
                    _fileName = value;
                    RaisePropertyChanged("FileName");
                }
            }
        }

        private FileInfo _file;
        public FileInfo File
        {
            get { return _file; }
            set
            {
                if (_file != value)
                {
                    _file = value;
                    RaisePropertyChanged("File");
                }
            }
        }



        public LogFileModel(FileInfo fi)
        {
            this.LastWriteTime = fi.LastWriteTime;
            this.FileName = fi.Name;
            this.File = fi;
        }
        public LogFileModel() { }

        protected virtual void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
        public event PropertyChangedEventHandler PropertyChanged;
    }
}
